﻿namespace ACCOUNTING.LVY.Business
{
    using ACCOUNTING;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Data;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;

    public class DefaultValue
    {
        private string mDienGiai = "";
        private string mGiaTri = "";
        private string mLoai = "";
        private string mMa = "";
        private string mNghiepVu = "";

        public DataTable GetDSLien(int intSoLien)
        {
            DataTable table;
            string commandText = "";
            try
            {
                commandText = " SELECT TOP " + Conversions.ToString(intSoLien) + " * FROM HT_DSLien ORDER BY Khoa";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable LoadDinhKhoanList(string strCondition = "")
        {
            DataTable table;
            string commandText = "";
            string str2 = "";
            try
            {
                if (strCondition.Trim() != "")
                {
                    str2 = " And " + strCondition;
                }
                commandText = "SELECT DF.NghiepVu as KhoaNghiepVu, DF.Ma, MN.Ten" + modGeneral.H_LANGUAGE + " as NghiepVu, DF.DienGiai" + modGeneral.H_LANGUAGE + " As DienGiai, DF.GiaTri, TK.SoTaiKhoan  FROM HT_DefaultValue DF left join DM_TaiKhoan TK on DF.GiaTri = TK.Khoa  left join HT_Menu MN on rtrim(DF.NghiepVu) = Rtrim(MN.Khoa) WHERE DF.LoaiMacDinh = 'DK' " + str2 + " ORDER BY NghiepVu";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable LoadKiHieuList(string strCondition = "")
        {
            DataTable table;
            string commandText = "";
            string str2 = "";
            try
            {
                if (strCondition.Trim() != "")
                {
                    str2 = " WHERE " + strCondition;
                }
                commandText = " SELECT * FROM HT_SoKiHieu " + str2 + " ORDER BY SoKiHieu ";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable LoadLienList(int intSoLien, string strCondition = "")
        {
            DataTable table;
            string commandText = "";
            string str2 = "";
            try
            {
                if (strCondition.Trim() != "")
                {
                    str2 = " WHERE " + strCondition;
                }
                commandText = " SELECT TOP " + Conversions.ToString(intSoLien) + " * FROM HT_DSLien " + str2 + " ORDER BY Khoa";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable ShowList(string strCondition = "")
        {
            DataTable table;
            string commandText = "";
            string str2 = "";
            try
            {
                if (strCondition.Trim() != "")
                {
                    str2 = " WHERE " + strCondition;
                }
                commandText = " SELECT * FROM HT_DefaultValue " + str2 + " ORDER BY MA";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable ShowLoaiHoaDonIn()
        {
            DataTable table;
            string commandText = "";
            try
            {
                commandText = " SELECT  * FROM HT_LoaiHoaDonIn WHERE Khoa = '" + modGeneral.H_LOAIHOADONINMACDINH + "' ORDER BY Khoa";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable ShowLoaiIn()
        {
            DataTable table;
            string commandText = "";
            try
            {
                commandText = " SELECT  * FROM HT_LoaiIn ORDER BY Khoa";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public string DienGiai
        {
            get
            {
                return this.mDienGiai;
            }
            set
            {
                this.mDienGiai = value;
            }
        }

        public string GiaTri
        {
            get
            {
                return this.mGiaTri;
            }
            set
            {
                this.mGiaTri = value;
            }
        }

        public string Loai
        {
            get
            {
                return this.mLoai;
            }
            set
            {
                this.mLoai = value;
            }
        }

        public string Ma
        {
            get
            {
                return this.mMa;
            }
            set
            {
                this.mMa = value;
            }
        }

        public string NghiepVu
        {
            get
            {
                return this.mNghiepVu;
            }
            set
            {
                this.mNghiepVu = value;
            }
        }
    }
}

